﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace WebApp.Common.EFQuery
{
    public static class HtmlHelperExtension
    {
        public static MvcHtmlString SearchInputFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper,
                Expression<Func<TModel, TProperty>> expression,
                QueryMethod queryMethod, DbType dbtype = DbType.String, IDictionary<string, Object> htmlAttributes=null)
        {
            if (htmlAttributes == null) htmlAttributes = new Dictionary<string, object>();

            htmlAttributes.Add("data-query", (int)queryMethod);
            htmlAttributes.Add("data-fldtype", (int)dbtype);

            return htmlHelper.TextBoxFor(expression, htmlAttributes);
        }

    }
}
